home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / gnu / gnulib / dkbtrace / pbmplus / source / libtiff / tif_stri.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-19  |  2.6 KB  |  89 lines

  1. #ifndef lint
  2. static char rcsid[] = "$Header: /usr/people/sam/tiff/libtiff/RCS/tif_strip.c,v 1.3 91/08/19 14:40:47 sam Exp $";
  3. #endif
  4.  
  5. /*
  6.  * Copyright (c) 1991 Sam Leffler
  7.  * Copyright (c) 1991 Silicon Graphics, Inc.
  8.  *
  9.  * Permission to use, copy, modify, distribute, and sell this software and 
  10.  * its documentation for any purpose is hereby granted without fee, provided
  11.  * that (i) the above copyright notices and this permission notice appear in
  12.  * all copies of the software and related documentation, and (ii) the names of
  13.  * Sam Leffler and Silicon Graphics may not be used in any advertising or
  14.  * publicity relating to the software without the specific, prior written
  15.  * permission of Sam Leffler and Silicon Graphics.
  16.  * 
  17.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  18.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  19.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  20.  * 
  21.  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  22.  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  23.  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  24.  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
  25.  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
  26.  * OF THIS SOFTWARE.
  27.  */
  28.  
  29. /*
  30.  * TIFF Library.
  31.  *
  32.  * Strip-organized Image Support Routines.
  33.  */
  34. #include "tiffioP.h"
  35.  
  36. /*
  37.  * Compute which strip a (row,sample) value is in.
  38.  */
  39. u_int
  40. TIFFComputeStrip(tif, row, sample)
  41.     TIFF *tif;
  42.     u_long row;
  43.     u_int sample;
  44. {
  45.     TIFFDirectory *td = &tif->tif_dir;
  46.     u_int strip;
  47.  
  48.     strip = row / td->td_rowsperstrip;
  49.     if (td->td_planarconfig == PLANARCONFIG_SEPARATE) {
  50.         if (sample >= td->td_samplesperpixel) {
  51.             TIFFError(tif->tif_name,
  52.                 "%d: Sample out of range, max %d",
  53.                 sample, td->td_samplesperpixel);
  54.             return (0);
  55.         }
  56.         strip += sample*td->td_stripsperimage;
  57.     }
  58.     return (strip);
  59. }
  60.  
  61. /*
  62.  * Compute how many strips are in an image.
  63.  */
  64. u_int
  65. TIFFNumberOfStrips(tif)
  66.     TIFF *tif;
  67. {
  68.     TIFFDirectory *td = &tif->tif_dir;
  69.  
  70.     return (td->td_rowsperstrip == 0xffffffff ?
  71.          (td->td_imagelength != 0 ? 1 : 0) :
  72.          howmany(td->td_imagelength, td->td_rowsperstrip));
  73. }
  74.  
  75. /*
  76.  * Compute the # bytes in a (row-aligned) strip.
  77.  */
  78. u_long
  79. TIFFStripSize(tif)
  80.     TIFF *tif;
  81. {
  82.     TIFFDirectory *td = &tif->tif_dir;
  83.     u_long rowsperstrip = td->td_rowsperstrip;
  84.     
  85.     if (rowsperstrip == (u_long)-1)
  86.         rowsperstrip = td->td_imagelength;
  87.     return (rowsperstrip * TIFFScanlineSize(tif));
  88. }
  89.